import { createRouter, createWebHistory } from 'vue-router'
import List from '../views/List.vue'
import Product from '../components/Product.vue'
import Cart from '../views/Cart.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/list',
      name: 'home',
      component: List
    },
    {
      path: '/about',
      name: 'about',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/AboutView.vue')
    },
    {
      path: '/cart',
      name: 'cart',
      component: Cart
    },
    {
      path: '/product/:id',
      meta:{
        title:'商品详情'
      },
      component: () => import('../views/Product.vue')
    },
    {
      path:'/',
      name:'product',
      component:Product
    },
    {
      path: '/:list*',
      redirect:'/list',
    }
  ]
})

export default router
